package com.bw.spring.security.controller;


import com.bw.spring.security.exception.UserException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
public class ControllerExceptionHandller {


    @ExceptionHandler(UserException.class)
    @ResponseBody
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public Map<String,String> exceptionHandller(final UserException e){
        HashMap<String,String> map = new HashMap<String,String>(){{
                put("id",e.getId());
                put("message",e.getMessage());
        }};
        return map;
    }
}
